load("//bazel:tachyon.bzl", "if_gpu_is_configured")
load("//bazel:tachyon_cc.bzl", "tachyon_cc_library", "tachyon_cc_unittest")

package(default_visibility = ["//visibility:public"])

tachyon_cc_library(
    name = "fixed_base_msm",
    hdrs = ["fixed_base_msm.h"],
    deps = [
        ":msm_ctx",
        "//tachyon/base:parallelize",
        "//tachyon/base/containers:container_util",
        "//tachyon/math/base:bit_iterator",
        "//tachyon/math/base:semigroups",
        "//tachyon/math/geometry:point_conversions",
    ],
)

tachyon_cc_library(
    name = "glv",
    hdrs = ["glv.h"],
    deps = [
        "//tachyon/math/base:bit_iterator",
        "//tachyon/math/base/gmp:bit_traits",
        "//tachyon/math/base/gmp:signed_value",
        "//tachyon/math/elliptic_curves:semigroups",
        "//tachyon/math/matrix:gmp_num_traits",
    ],
)

tachyon_cc_library(
    name = "msm_ctx",
    hdrs = ["msm_ctx.h"],
    deps = ["//tachyon:export"],
)

tachyon_cc_library(
    name = "msm_util",
    hdrs = ["msm_util.h"],
    deps = ["//tachyon/base:template_util"],
)

tachyon_cc_library(
    name = "variable_base_msm",
    hdrs = ["variable_base_msm.h"],
    deps = ["//tachyon/math/elliptic_curves/msm/algorithms/pippenger:pippenger_adapter"],
)

tachyon_cc_library(
    name = "variable_base_msm_gpu",
    hdrs = ["variable_base_msm_gpu.h"],
    deps = ["//tachyon/math/elliptic_curves/msm/algorithms/icicle"],
)

tachyon_cc_unittest(
    name = "msm_unittests",
    srcs = [
        "fixed_base_msm_unittest.cc",
        "glv_unittest.cc",
        "variable_base_msm_unittest.cc",
    ],
    deps = [
        ":glv",
        "//tachyon/math/elliptic_curves/bls12/bls12_381:g1",
        "//tachyon/math/elliptic_curves/bls12/bls12_381:g2",
        "//tachyon/math/elliptic_curves/bn/bn254:g1",
        "//tachyon/math/elliptic_curves/bn/bn254:g2",
        "//tachyon/math/elliptic_curves/msm/test:fixed_base_msm_test_set",
        "//tachyon/math/elliptic_curves/msm/test:variable_base_msm_test_set",
    ],
)

tachyon_cc_unittest(
    name = "msm_gpu_unittests",
    srcs = if_gpu_is_configured(["variable_base_msm_gpu_unittest.cc"]),
    deps = [
        ":variable_base_msm_gpu",
        "//tachyon/device/gpu:scoped_mem_pool",
        "//tachyon/device/gpu:scoped_stream",
        "//tachyon/math/elliptic_curves/msm/test:variable_base_msm_test_set",
    ],
)
